extends EnemyBase

class_name RegularEnemy

const BULLET_SPEED_DELTA = 500

@export var enemy_bullet_scene: PackedScene

func _ready() -> void:
	super()
	add_to_group("enemy_regular")
	flying_direction = Vector2.DOWN
	fire_timer.wait_time = randf_range(1, 2)
	fire_timer.start()

func _process(delta: float) -> void:
	super(delta)

func fire() -> void:
	var enemy_bullet = enemy_bullet_scene.instantiate()
	enemy_bullet.position.x = position.x
	enemy_bullet.position.y = position.y
	enemy_bullet.speed = speed + BULLET_SPEED_DELTA
	get_parent().add_child(enemy_bullet)

func animate_explosion() -> void:
	$AnimatedSprite2D.play("explosion")
	await $AnimatedSprite2D.animation_finished
